package com.zxl.live.screen.call.model.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zxl.live.screen.screen.constant.LockerEnv;

import org.json.JSONObject;

/**
 * Created by Administrator on 2017/12/5.
 */

public class ThemeBean implements Parcelable {

    public static final String TYPE_MP4 = "mp4";

    public static final String TYPE_GIF = "gif";

    public static final int ERROR_REQUEST_NET = 1;
    public static final int ERROR_EXCEPTION = 2;

    public String title;

    public String banner;

    public String src;

    public String yes;

    public String no;

    public String type;

    public String defaultColor;

    public String defaultName;

    public String defaultNumber;

    public String defaultIcon;

    public ThemeBean(String title, String banner, String src, String yes, String no, String defaultColor, String defaultName, String defaultNumber, String defaultIcon) {
        this.title = title;
        this.banner = banner;
        this.src = src;
        this.yes = yes;
        this.no = no;
        this.defaultColor = defaultColor;
        this.defaultName = defaultName;
        this.defaultNumber = defaultNumber;
        this.defaultIcon = defaultIcon;
    }

    public void parse(JSONObject jsonObject) {
        title = jsonObject.optString("title");
        banner = jsonObject.optString("banner");
        src = jsonObject.optString("src");
        yes = jsonObject.optString("yes");
        no = jsonObject.optString("no");
        type = jsonObject.optString("type",TYPE_MP4);
    }

    public String getDownloadPath() {
        return LockerEnv.Path.LOCAL_CALL + src.hashCode() + ".pm4";
    }

    public ThemeBean() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeString(this.banner);
        dest.writeString(this.src);
        dest.writeString(this.yes);
        dest.writeString(this.no);
        dest.writeString(this.type);
        dest.writeString(this.defaultColor);
        dest.writeString(this.defaultName);
        dest.writeString(this.defaultNumber);
        dest.writeString(this.defaultIcon);
    }

    protected ThemeBean(Parcel in) {
        this.title = in.readString();
        this.banner = in.readString();
        this.src = in.readString();
        this.yes = in.readString();
        this.no = in.readString();
        this.type = in.readString();
        this.defaultColor = in.readString();
        this.defaultName = in.readString();
        this.defaultNumber = in.readString();
        this.defaultIcon = in.readString();
    }

    public static final Parcelable.Creator<ThemeBean> CREATOR = new Parcelable.Creator<ThemeBean>() {
        @Override
        public ThemeBean createFromParcel(Parcel source) {
            return new ThemeBean(source);
        }

        @Override
        public ThemeBean[] newArray(int size) {
            return new ThemeBean[size];
        }
    };
}
